package com.baidu.mpks.security;


import lombok.Data;
import org.apache.shiro.authz.Permission;

@Data
public class ObjectPermission implements Permission {

    private String permissionCode;
    private Class targetType;
    private Integer targetId;

    @Override
    public boolean implies(Permission p) {
        if (p instanceof ObjectPermission && this.permissionCode != null && this.targetType != null && this.targetId != null) {
            ObjectPermission temp = (ObjectPermission)p;
            return this.permissionCode.equals(temp.getPermissionCode()) && this.targetType.equals(temp.getTargetType()) && this.targetId.equals(temp.getTargetId());
        } else {
            return false;
        }
    }
}
